/**
 * Created by zxh on 2016/12/12.
 */
import React from 'react';
import {
  Form,
  Col,
  Input,
  Button,
  DatePicker,
  Select,
  Table,
  Icon,
  Radio,
  InputNumber,
  Checkbox,
  Modal,
  message,
  notification,
  Affix,
  Upload
} from 'antd';

const FormItem = Form.Item;

import Logger from '../../utils/Logger';
import FieldConverter from './FieldConverter';
import BaseElementConverter from './BaseElementConverter';
import UploadElementConverter from './UploadElementConverter';
import QueryElementConverter from './QueryElementConverter';
import ImageFileConverter from './ImageFileConverter';
import FileUpConverter from './FileUpConverter';
import SelectTagConverter from './SelectTagConverter';
import SelectByDefaultValueConverter from './SelectByDefaultValueConverter';
import ResponseDataConverter from './ResponseDataConverter';
import CheckboxConverter from './CheckboxConverter';
import RadioConverter from './RadioConverter';
import SelectByRequestValueConverter from './SelectByRequestValueConverter';
import ImageUpAndVIewConverter from './ImageUpAndVIewConverter';

const logger = Logger.getLogger('FormFieldConverter');

class FormFieldConverter extends FieldConverter {

  constructor() {
    super();
    this.addConverter(new BaseElementConverter());
    this.addConverter(new UploadElementConverter());
    this.addConverter(new QueryElementConverter());
    this.addConverter(new ImageFileConverter());
    this.addConverter(new FileUpConverter());
    this.addConverter(new SelectTagConverter());
    this.addConverter(new SelectByDefaultValueConverter());
    this.addConverter(new ResponseDataConverter());
    this.addConverter(new CheckboxConverter());
    this.addConverter(new RadioConverter());
    this.addConverter(new SelectByRequestValueConverter());
    this.addConverter(new ImageUpAndVIewConverter());
  }

  /**
   * 辅助函数
   *
   * @param formItem
   * @param field
   * @returns {XML}
   */
  colWrapper(formItem, field) {
    return (
      <FormItem key={field.key} className={field.formItemClassName} label={field.title} labelCol={field.labelCol != undefined ? field.labelCol : {span: 6}} wrapperCol={ field.wrapperCol != undefined  ? field.wrapperCol : {span : 18} }>
        {formItem}
      </FormItem>
    );
  }
}

export default FormFieldConverter;
